package com.example.lynandroidbeta

import android.app.Service
import android.content.Intent
import android.os.Handler
import android.os.HandlerThread
import android.os.IBinder
import android.widget.Toast

class MyAidlService : Service() {
    val handlerThread = HandlerThread("dfjdsslfjdslfkjdsk")

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Toast.makeText(applicationContext, "MyService StartCommand", Toast.LENGTH_SHORT).show()
        return super.onStartCommand(intent, flags, startId)
    }

    override fun onBind(intent: Intent?): IBinder {
        handlerThread.start()
        return mBinder
    }

    private val mBinder = object : IMyAidlInterface.Stub() {
        override fun fight(msg: String) {
            Handler(handlerThread.looper).post {
                Toast.makeText(applicationContext, msg, Toast.LENGTH_SHORT).show()
            }
        }
    }
}